﻿using System;
using System.Windows;
using System.Windows.Controls;

namespace WpfUMLTry1
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            View.Switcher.pageSwitcher = this;
            View.Switcher.Switch(new View.MainMenu());
        }

        public void Navigate(Page nextPage)
        {
            this.Content = nextPage;
            this.DataContext = null;
           // this.mainPage.Content = nextPage;
          //  this.mainPage.DataContext = null;
        }

        public void Navigate(Page newPage, ViewModel.VM_Base newVM)
        {
            this.Content = newPage;
            this.DataContext = newVM;
           // this.mainPage.Content = newPage;
           // this.mainPage.DataContext = newVM;
        }


        public void Navigate(Page nextPage, object state)
        {
            this.Content = nextPage;
            //this.mainPage.Content = nextPage;
            View.ISwitchable s = nextPage as View.ISwitchable;

            if (s != null)
                s.UtilizeState(state);
            else
                throw new ArgumentException("NextPage is not ISwitchable! " + nextPage.Name.ToString());
                
        }
    }
}
